package com.lht.admin.controller;

import com.lht.admin.service.IndexService;
import com.lht.admin.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @描述:首页的控制层
 * @创建人: JaccePon
 * @创建日期: 2020年02月08日 22:04
 */
@RestController
@RequestMapping("/index/main/")
public class IndexController extends AbstractController{

    @Autowired
    private IndexService indexService;
    /**
     * 获取顶部的四项统计
     */
    @RequestMapping("/orderCount")
    public R orderCount() {

       HashMap<String, String> result = indexService.orderCount();

        return R.ok().put("result", result);
    }

    /**
     * 获取产品占比
     */
    @RequestMapping("/productCount")
    public R productCount() {

        List<HashMap<String, Object>> result = indexService.productCount();

        return R.ok().put("result", result);
    }
    /**
     * 获取订单进度统计
     */
    @RequestMapping("/processCount")
    public R processCount() {

        List<HashMap<String, Object>> result = indexService.processCount();

        return R.ok().put("result", result);
    }
    /**
     * 获取日趋势统计
     */
    @RequestMapping("/latestDaysCount")
    public R latestDaysCount() {

        List<Integer> result = indexService.latestDaysCount(31);

        return R.ok().put("result", result);
    }
    /**
     * 获取半年的业绩统计
     */
    @RequestMapping("/halfYearCount")
    public R halfYearCount() {

        Map<String,Map<String, Object>> result = indexService.halfYearCount();

        return R.ok().put("result", result);
    }
}
